package com.yf1706.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.yf1706.bean.EmpPositionChangeRecord;
import com.yf1706.dao.jpa.IPositionChangeJDAO;
import com.yf1706.dao.mybatis.IPositionChangeMDAO;

@Service
@Transactional(rollbackFor=Exception.class)
public class ApproveService {
	@Autowired
	private IPositionChangeJDAO pcjdao;
	@Autowired
	private IPositionChangeMDAO pcmdao;
	
	//新增职位变动申请记录
	public void addPositionChangeRecord(EmpPositionChangeRecord pcr) {
		pcjdao.save(pcr);
	}
	
	//分页查询所有职位变动申请记录
	public List<EmpPositionChangeRecord> queryAllEPCR(){
		return pcmdao.queryAll();
	}
	
	//分页模糊查询所有职位变动申请记录
	public List<EmpPositionChangeRecord> queryBySearch(String searchValue){
		return pcmdao.queryBySearch(searchValue);
	}
	
	//根据审批员工编号查询所有待审批职位变动申请记录
	public int queryApproveNum(int approverId){
		return pcmdao.queryRemindMsg(approverId,0);
	}

	//根据申请员工编号查询所有待修改职位变动申请记录
	public int queryEditNum(int applyEmpId){
		return pcmdao.queryRemindMsg(0,applyEmpId);
	}
	
	//查询职位变动申请记录
	public EmpPositionChangeRecord findEPCR(int recordId){
		return pcjdao.findByRecordId(recordId);
	}

	//删除职位变动申请记录
	public void deleteEPCR(int recordId){
		pcjdao.delete(pcjdao.findByRecordId(recordId));
	}
}
